#include "CInvalidationDescriptor.h"


CInvalidationDescriptor::CInvalidationDescriptor(void):IDescriptorData(DESCRIPTOR_TAG_INVALIDATION)

{	
}

CInvalidationDescriptor::~CInvalidationDescriptor(void)
{
}

void CInvalidationDescriptor::GetData(BYTE* buff  , int &len)
{ 

	DWORD display_mask = 0x00000000;
	for ( map<int,bool>::iterator iter = m_mapSlotsStatus.begin();iter!=m_mapSlotsStatus.end();++iter)
	{
		if (true==iter->second)
		{
			display_mask = display_mask |(0x01<< (iter->first -1)) ;
		}else
		{
			display_mask = display_mask &(~(0x01<< (iter->first -1))) ;
		}
	}
 
	CBuffer stBuffer(buff,DESCRIPTOR_MAXLEN);
	PACK_DESCRIPTOR_BUFFER_START(stBuffer,DESCRIPTOR_TAG_INVALIDATION);
	stBuffer.Write((DWORD)display_mask);
	len = PACK_DESCRIPTOR_BUFFER_END(stBuffer);   //11 

}

void CInvalidationDescriptor::SetSlotStatus(int nSlotId,bool bOpened)
{
	m_mapSlotsStatus[nSlotId]=bOpened;
}